package pl.eurobank.dev.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.*;

@Entity
@Table(name = "investment_fund_unit_type")
public class InvestmentFundUnitType {

	private int id;

	@NotEmpty()
	@Size(min = 3)
	private String fundUnitName;

	private InvestmentFund investmentFund;

	private float actualPrice;

	private float salesCommission;

	private float buingCommission;

	@SequenceGenerator(name = "inv_fund_unit_type_seq", sequenceName = "investment_fund_unit_type_seq")
	@Id
	@GeneratedValue(generator = "inv_fund_unit_type_seq")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "fund_unit_name", unique = true, nullable = false, length = 255)
	public String getFundUnitName() {
		return fundUnitName;
	}

	public void setFundUnitName(String invFundUnitName) {
		this.fundUnitName = invFundUnitName;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "investment_fund_id", nullable = false)
	public InvestmentFund getInvestmentFund() {
		return this.investmentFund;
	}

	public void setInvestmentFund(InvestmentFund investmentFund) {
		this.investmentFund = investmentFund;
	}

	@Column(name = "actual_price", unique = false, nullable = false)
	public float getActualPrice() {
		return actualPrice;
	}

	public void setActualPrice(float actualPrice) {
		this.actualPrice = actualPrice;
	}

	@Column(name = "sales_commission", unique = false, nullable = true)
	public float getSalesCommission() {
		return salesCommission;
	}

	public void setSalesCommission(float salesCommission) {
		this.salesCommission = salesCommission;
	}

	@Column(name = "buing_commission", unique = false, nullable = true)
	public float getBuingCommission() {
		return buingCommission;
	}

	public void setBuingCommission(float buingCommission) {
		this.buingCommission = buingCommission;
	}

	private Set<ClientHasInvestFundUnit> ClientHasInvestFundUnit = new HashSet<ClientHasInvestFundUnit>(
			0);

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "investmentFundUnitType")
	public Set<ClientHasInvestFundUnit> getClientHasInvestFundUnit() {
		return this.ClientHasInvestFundUnit;
	}

	public void setClientHasInvestFundUnit(
			Set<ClientHasInvestFundUnit> ClientHasInvestFundUnit) {
		this.ClientHasInvestFundUnit = ClientHasInvestFundUnit;
	}

}